<#include "../public/header.html"/>
<form method="post" class="form-x form-auto">

   <div class="form-group">
		<div class="label">
			<label for="name">是否全局配置</label>
		</div>
		<div class="field">
			<label><input name="is_global" value="1" type="radio">是</label>
			<label><input name="is_global" value="0" type="radio" checked="checked">否</label>
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label for="name">应用</label>
		</div>
		<div class="field">
			<select class="input w200" id="app_name" name="app_name">
			    <option value="">请选择应用..</option>
				<#if apps??>
				<#list apps as app><option value="${app.name}">${app.name}</option></#list>
			   </#if>
			</select>
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label for="name">版本</label>
		</div>
		<div class="field">
			<select class="input w200" dataType="Require" name="version">
				<option selected="selected" value="0.0.0">0.0.0</option>
			</select>
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label for="password">环境</label>
		</div>
		<div class="field">
			<select class="input" name="env" dataType="Require">
			    <option value="">请选择环境..</option>
				<#if envs??>
				<#list envs as env><option value="${env}">${env}</option></#list>
			   </#if>
			</select>
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label>配置文件</label>
		</div>
		<div class="field">
			<div class="media-inline">
				<a class="button input-file bg-green" href="javascript:void(0);">
					<span>+ 选择文件</span> <input size="100" type="file" class="J_upload" />
				</a> <span class="text-red">可以选择上传或者在下面直接输入</span>
			</div>
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label for="name">文件名</label>
		</div>
		<div class="field">
			<input type="text" class="input w200" id="file_name" name="file_name"
				placeholder="如:mysql.properties" dataType="Require" />
		</div>
	</div>
	<div class="form-group">
		<div class="label">
			<label for="name">文件内容</label>
		</div>
		<div class="field">
			<textarea id="contents" name="contents" class="input" rows="8" cols="100" dataType="Require"></textarea>
		</div>
	</div>
	<div class="form-button">
		<input type="button" class="button bg-sub J_ajaxSubmit" value="新增" />
	</div>
</form>
<script type="text/javascript">
$(function(){
	var $fileInput = $('.J_upload');
    $fileInput.ajaxUploader({
      action_url: './upload',
      input_name: 'file',
      onSubmit: function(id, fileName){},
      onFinish: function(fileName,content){
    	$('#file_name').val(fileName);
	    $('#contents').val(content);
     }
   });
    
    //
    $("input[name='is_global']").change(function() {
		var $selectedvalue = $("input[name='is_global']:checked").val();
		if ($selectedvalue == 1) {
			$('#app_name').attr('disabled',true);
		} else {
			$('#app_name').removeAttr("disabled"); 
		}
	});
});
</script>
<#include "../public/footer.html"/>
